<?php
/**
 * The model for grid quick action
 *
 *
 * @author     Moldovan Calin <mcalin45@gmail.com>
 * @author     Vlad Razvan <razvanvlad1982@yahoo.com>
 * @author     Jipa Ciprian <ciprian.jipa@yahoo.com>
 * @copyright  Copyright (c) 2012
 * @version    $Id: User.php 43 2012-09-27 07:14:48Z mcalin45@gmail.com $
 */

namespace Crc\Grid;

/**
 * Class for quick actions.
 *
 * @author     Moldovan Calin <mcalin45@gmail.com>
 * @author     Vlad Razvan <razvanvlad1982@yahoo.com>
 * @author     Jipa Ciprian <ciprian.jipa@yahoo.com>
 * @copyright  Copyright (c) 2012
 */

abstract class QuickActions
{
    /**
     * Entity
     *
     * @var string
     */
    protected $_entity;

    /**
     * Repository
     *
     * @var string
     */
    protected $_repository;

    public function setEntity($entity)
    {
        $this->_entity = $entity;
        $doctrine = \Zend_Registry::get('doctrine');
        $entityManager = $doctrine->getEntityManager();
        $this->_repository = $entityManager->getRepository($this->_entity);
        return $this;
    }

    public function active($ids)
    {
        foreach ($this->_repository->findById($ids) as $obj) {
            $obj->setStatus(1);
        }
    }

    public function inactive($ids)
    {
        foreach ($this->_repository->findById($ids) as $obj) {
            $obj->setStatus(0);
        }
    }
}